/**
 * 班次
 */
export function getJobShift(data) {
  if (data.morningShift && data.middleShift && data.eveningShift && data.otherShift) {
    return '排班'
  } else if ((data.morningShift && data.middleShift) || (data.morningShift && data.eveningShift) || (data.eveningShift && data.middleShift) || (data.morningShift && data.otherShift) || (data.middleShift && data.otherShift) || (data.eveningShift && data.otherShift)) {
    return '排班'
  } else {
    if (data.morningShift) {
      return `早班 ${data.morningShiftStart} - ${data.morningShiftEnd}`
    } else if (data.middleShift) {
      return `中班 ${data.middleShiftStart} - ${data.middleShiftEnd}`
    } else if (data.eveningShift) {
      return `晚班 ${data.eveningShiftStart} - ${data.eveningShiftEnd}`
    } else if (data.otherShift) {
      return `其他班次 ${data.otherShiftStart} - ${data.otherShiftEnd}`
    }
  }
}


/**
 * 佣金
 */
export function getPrice(data) {
  return data.jobPayLower == data.jobPayUpper ? data.jobPayLower : (data.jobPayLower + '-' + data.jobPayUpper);
}

/**
 * 佣金单位
 */
export function commissionUnit(code) {
  let state = "元/时"
  switch (code) {
    case 1:
      state = "元/时"
      break;
    case 2:
      state = "元/日"
      break;
    case 3:
      state = "元/月"
  }
  return state

}

/**
 * 结算方式
 */
export function settlementType(data) {
  return data.settlementType == 1 ? '日结' : (data.settlementType == 2 ? '周结' : '月结');
}

// 工作年限
export function experienceRequire(code) {
  let state = "不限"
  switch (code) {
    case -1:
      state = "不限"
      break;
    case 0:
      state = "1年以内"
      break;
    case 1:
      state = "1-3年"
      break;
    case 3:
      state = "3-5年"
      break;
    case 5:
      state = "5-10年"
      break;
    case 10:
      state = "10年以上"
      break;
  }
  return state
}


/**
 * 获取年龄
 */
export function getAge(data) {
  if (!data.ageRequireLower && !data.ageRequireUpper) {
    return "不限年龄";
  }

  if (data.ageRequireLower < data.ageRequireUpper) {
    return data.ageRequireLower + "-" + data.ageRequireUpper + "岁";
  }

  if (data.ageRequireLower == data.ageRequireUpper) {
    return ageRequireLower + "岁";
  }
}


// 性别
export function genderRequire(code) {
  let state = "不限性别"
  switch (code) {
    case 0:
      state = "不限性别"
      break;
    case 1:
      state = "男"
      break;
    case 2:
      state = "女"
      break;
  }
  return state
}

// 学历
export function educationRequire(code) {
  let state = "不限学历"
  switch (code) {
    case 0:
      state = "不限学历"
      break;
    case 1:
      state = "小学"
      break;
    case 2:
      state = "初中"
      break;
    case 3:
      state = "中专/技校"
      break;
    case 4:
      state = "高中"
      break;
    case 5:
      state = "大专"
      break;
    case 6:
      state = "本科及以上"
      break;
  }
  return state
}


// 计算距离distance meter 米
export function getDistance(meter) {
  let name = ""
  if (meter > 0) {
    if ((meter / 1000) > 50) {
      name = ">50公里"
    } else if ((meter / 1000) >= 1) {
      name = Number((meter / 1000)).toFixed(1) + "公里"
    } else {
      name = Math.round(meter) + "米"
    }
  } else {
    name = "0米"
  }
  return name
}